<template>
  <el-table-column
    :type="type"
    :label="label"
    :class-name="className"
    :label-class-name="labelClassName"
    :property="property"
    :prop="prop"
    :width="width"
    :min-width="minWidth"
    :render-header="renderHeader"
    :sortable="sortable"
    :sort-method="sortMethod"
    :sort-by="sortBy"
    :resizable="resizable"
    :column-key="columnKey"
    :align="align"
    :header-align="headerAlign"
    :show-tooltip-when-overflow="showTooltipWhenOverflow"
    :show-overflow-tooltip="showOverflowTooltip"
    :fixed="fixed"
    :formatter="formatter"
    :selectable="selectable"
    :reserve-selection="reserveSelection"
    :filter-method="filterMethod"
    :filtered-value="filteredValue"
    :filters="filters"
    :filter-placement="filterPlacement"
    :filter-multiple="filterMultiple"
    :index="index"
    :sort-orders="sortOrders"
  ></el-table-column>
</template>

<script>
  import formatter from './formatter';

  export default {
    name: 'WfElTableColumn',
    props: {
      type: {
        type: String,
        default: 'default', // 类型： default 默认，text 文本, boolean 布尔， map {key: value, ...}, array [...value]
      },

      label: {
        type: String,
        required: true,
      },
      className: {
        type: String,
        default: undefined,
      },
      labelClassName: {
        type: String,
        default: undefined,
      },
      property: {
        type: String,
        default: undefined,
      },
      prop: {
        type: String,
        default: undefined,
      },
      width: {
        type: Object,
        default: () => ({}),
      },
      minWidth: {
        type: Object,
        default: () => ({}),
      },
      renderHeader: {
        type: Function,
        default: undefined,
      },
      sortable: {
        type: [Boolean, String],
        default: false,
      },
      sortMethod: {
        type: Function,
        default: undefined,
      },
      sortBy: {
        type: [String, Function, Array],
        default: undefined,
      },

      resizable: {
        type: Boolean,
        default: true,
      },
      columnKey: {
        type: String,
        default: undefined,
      },
      align: {
        type: String,
        default: undefined,
      },
      headerAlign: {
        type: String,
        default: undefined,
      },
      showTooltipWhenOverflow: {
        type: Boolean,
        default: true,
      },
      showOverflowTooltip: {
        type: Boolean,
        default: true,
      },
      fixed: {
        type: [Boolean, String],
        default: undefined,
      },
      formatter: {
        type: Function,
        default: formatter,
      },
      formatTexts: {
        type: [String, Array, Object],
        default: undefined,
      },
      selectable: {
        type: Function,
        default: undefined,
      },
      reserveSelection: {
        type: Boolean,
        default: false,
      },
      filterMethod: {
        type: Function,
        default: undefined,
      },
      filteredValue: {
        type: Array,
        default: () => undefined,
      },
      filters: {
        type: Array,
        default: () => undefined,
      },
      filterPlacement: {
        type: String,
        default: undefined,
      },
      filterMultiple: {
        type: Boolean,
        default: true,
      },
      index: {
        type: [Number, Function],
        default: undefined,
      },
      sortOrders: {
        type: Array,
        default() {
          return ['ascending', 'descending', null];
        },
        validator(val) {
          return val.every(order => ['ascending', 'descending', null].indexOf(order) > -1);
        },
      },
    },
  };
</script>
